package com.kwq.designPattern.construct.Filter;

import lombok.Data;

import java.util.List;

/**
 * @author kangwanqiang
 * @date 2021/2/6
 * @description and 方式组装过滤器
 */
@Data
public class AndCriteria implements Criteria{
    private Criteria criteria;
    private Criteria otherCriteria;

    public AndCriteria(Criteria criteria, Criteria otherCriteria) {
        this.criteria = criteria;
        this.otherCriteria = otherCriteria;
    }

    @Override
    public List<Person> meetCriteria(List<Person> persons) {
        List<Person> firstCriteriaPersons = criteria.meetCriteria(persons);
        return otherCriteria.meetCriteria(firstCriteriaPersons);
    }
}
